package indi.h.security.encryption.sym;

import indi.h.security.Parameters;
import indi.h.security.encryption.AbstractCrypt;
import indi.h.security.encryption.Crypt;
import indi.h.security.encryption.CryptFactory;
import indi.h.security.encryption.CryptFactoryConfig;

public class SymCryptFactory implements CryptFactory {
	private CryptFactoryConfig<Enum<?>> cryptFactoryConfig;

	public static CryptFactory getInstance(Enum<?> e) {
		return getInstance(e, new SymFactoryConfig<Enum<?>>());
	}

	public static CryptFactory getInstance(Enum<?> e, CryptFactoryConfig<Enum<?>> factoryConfig) {
		SymCryptFactory scf = new SymCryptFactory();
		factoryConfig.init(e);
		scf.cryptFactoryConfig = factoryConfig;
		return scf;
	}

	@Override
	public Crypt createCrypt() {
		// TODO Auto-generated method stub
		return createCrypt(cryptFactoryConfig.getParameters());
	}

	@Override
	public Crypt createCrypt(Parameters cryptParam) {
		// TODO Auto-generated method stub
		AbstractCrypt newCrypt = cryptFactoryConfig.newCrypt();
		newCrypt.setParams(cryptParam);
		newCrypt.init();
		return newCrypt;
	}
}
